<nav class="navbar is-info is-fixed-top" role="navigation" aria-label="main navigation">
    <div class="container">
        <div class="navbar-brand">
            <a class="navbar-item" href="{{baseUrl}}">
                <img src="{{baseUrl}}/static/images/logo.png">
            </a>
            <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
               data-target="navbarBasic">
                <span aria-hidden="true"></span>
                <span aria-hidden="true"></span>
                <span aria-hidden="true"></span>
            </a>
        </div>
        <div id="navbarBasic" class="navbar-menu">
            <div class="navbar-start">
                <a class="navbar-item" href="{{baseUrl}}">首页</a>
                <a class="navbar-item" href="{{baseUrl}}/articles">文章</a>
                <a class="navbar-item" href="{{baseUrl}}/topics">讨论</a>
            </div>


            <div class="navbar-end">
                <div class="navbar-item">
                    <form id="searchForm" action="https://www.google.com/search" target="_blank">
                        <div class="control has-icons-right">
                            <input name="q" type="hidden" value="site:mlog.club">
                            <input name="q" class="input" type="text" maxlength="30" placeholder="搜索">
                            <span class="icon is-medium is-right"><i class="iconfont icon-search"></i></span>
                        </div>
                    </form>
                </div>

                <div class="navbar-item">
                    <div class="buttons">
                        {{/*<a class="button is-success" href="{{baseUrl}}/article/create"><strong>发表文章</strong></a>*/}}
                        <a class="button is-success" href="{{baseUrl}}/topic/create"><i
                                    class="iconfont icon-topic"></i>&nbsp;<strong>讨论</strong></a>
                    </div>
                </div>
                {{/*
                <div class="navbar-item has-dropdown is-hoverable">
                    <a class="navbar-link"><strong>发表</strong></a>
                    <div class="navbar-dropdown">
                        <a class="navbar-item" href="{{baseUrl}}/article/create">发表文章</a>
                        <a class="navbar-item" href="{{baseUrl}}/topic/create">发表讨论</a>
                    </div>
                </div>
                */}}


                {{if .CurrentUser}}
                    <div class="navbar-item has-dropdown is-hoverable" id="userDiv">
                        <a class="navbar-link"
                           href="{{userUrl .CurrentUser.Id}}"><strong>{{.CurrentUser.Nickname}}</strong>
                        </a>
                        <div class="navbar-dropdown">
                            <a class="navbar-item" href="{{baseUrl}}/topic/create"><i
                                        class="iconfont icon-topic"></i>&nbsp;发表讨论</a>
                            <a class="navbar-item" href="{{baseUrl}}/article/create"><i
                                        class="iconfont icon-publish"></i>&nbsp;发表文章</a>
                            <a class="navbar-item" href="{{baseUrl}}/user/{{.CurrentUser.Id}}/messages"><i
                                        class="iconfont icon-message"></i>&nbsp;消息</a>
                            <a class="navbar-item" href="{{baseUrl}}/user/edit/{{.CurrentUser.Id}}"><i
                                        class="iconfont icon-username"></i>&nbsp;编辑资料</a>
                            <a class="navbar-item" href="{{baseUrl}}/user/signout"><i class="iconfont icon-log-out"></i>&nbsp;退出登录</a>
                        </div>
                    </div>
                    <div id="msgcount_wapper" class="navbar-item" style="display: none;">
                        <div class="buttons">
                            <a id="msgcount" href="{{baseUrl}}/user/{{.CurrentUser.Id}}/messages"
                               class="button is-danger is-rounded msgcount">0</a>
                        </div>
                    </div>
                {{else}}
                    <div class="navbar-item">
                        <div class="buttons">
                            <a class="button is-primary" href="{{baseUrl}}/user/signup"><strong>注册</strong></a>
                            <a class="button is-light" href="javascript:toSignin()">登录</a>
                        </div>
                    </div>
                {{end}}
            </div>
        </div>
    </div>
</nav>

<script type="text/javascript">
  $(document).ready(function () {
    httpGet('{{baseUrl}}/user/msgcount').then(function (data) {
      if (data.count > 0) {
        $('#msgcount').text(data.count <= 99 ? data.count : '99+');
        $('#msgcount_wapper').show()
      }
    })
  });
</script>
